﻿		import mx.core.IFlexDisplayObject;
		import mx.core.DragSource;
		import mx.controls.*;
		import mx.events.*;
		import mx.managers.PopUpManager;
		import mx.managers.DragManager;
		import views.*;
		import model.ModelLocator;

		[Bindable]
		public var __model:ModelLocator = ModelLocator.getInstance();

		private var imageWidth:Number;
		private var imageHeight:Number;
		private var pop:IFlexDisplayObject;
		private var baseX:Number;
		private var baseY:Number;

		private function changesize():void{
			canv.scaleX=h_slider.value /100;
			canv.scaleY=h_slider.value /100;
		}

		private function canvMouseDown(event:MouseEvent):void{
			baseX=mouseX;
			baseY=mouseY;
			canv.addEventListener(MouseEvent.MOUSE_MOVE,canvMouseMove);
		}

		private function canvMouseUp(event:MouseEvent):void{
			canv.removeEventListener(MouseEvent.MOUSE_MOVE,canvMouseMove);
		}

		private function canvMouseMove(event:MouseEvent):void{
			canv.horizontalScrollPosition -= mouseX-baseX;
			canv.verticalScrollPosition -= mouseY-baseY;
			baseX=mouseX;
			baseY=mouseY;
		}

		private function onMouseMove_handler(event:MouseEvent):void{
			var dragInitiator:Canvas=Canvas(event.currentTarget);
			var ds:DragSource = new DragSource();
			DragManager.doDrag(dragInitiator,ds,event);
		}

		private function filterData(item:Object):Boolean {
			if (item.name == __model.currentKey) {
				return true;
			}else {
				return false;
			}
		}

		private function img_doubleclick(event:Event):void {
				__model.currentKey = event.target.toolTip;
				__model.tokeidata.filterFunction = filterData;
				__model.tokeidata.refresh();
				pop = PopUpManager.createPopUp(this, PopupWindow);
				PopUpManager.centerPopUp(pop);
		}

